//
//  ZBMutableDictionary.m
//  YouHui
//
//  Created by user on 11-11-27.
//  Copyright 2011 netease. All rights reserved.
//

#import "ZBMutableDictionary.h"

@implementation NSMutableDictionary(ZBExtenstion)

-(id)keyEqualString:(NSString*)key {
	NSArray *keys = [self allKeys];
	for (NSObject *keyItem in keys) {
        if (keyItem==key) {
            return keyItem;
        }
        if ([keyItem respondsToSelector:@selector(isEqualToString:)]) {
            if ([key isEqualToString:(NSString*)keyItem]) {
                return keyItem;
            }
        }
	}
	return nil;
}

-(id)objectForStringKey:(NSString*)key {
	id keyItem = [self keyEqualString:key];
	if (keyItem) {
		return [self objectForKey:keyItem];
	}
	return nil;
}

-(void)setObject:(id)anObject forStringKey:(NSString*)key {
	id keyItem = [self keyEqualString:key];
	if (keyItem) {
		[self setObject:anObject forKey:keyItem];
	} else {
		[self setObject:anObject forKey:key];
	}
}

-(void)removeObjectForStringKey:(NSString*)aKey {
	id keyItem = [self keyEqualString:aKey];
    if (keyItem) {
        [self removeObjectForKey:keyItem];
    }
}

@end
